/**
 * 
 */
package com.shine.icis.dao.imp;

import java.sql.CallableStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;

import com.shine.cotrun.sql.hibernate.CommQuery;
import com.shine.cotrun.web.comm.ListPage;
import com.shine.icis.dao.IChkLogDAO;
import com.shine.icis.dao.imp.BaseHibernateDAO;
import com.shine.icis.dao.param.ETLRunLogQueryParameters;
import com.shine.icis.hbean.ChkRunLog;

/**
 * @author zsy
 *
 */
public class ChkLogDAO extends BaseHibernateDAO implements IChkLogDAO {
	
	@Override
	public ListPage<ChkRunLog> findChkRunLogPage(ETLRunLogQueryParameters qp) {
		if (qp == null) {
			throw new IllegalArgumentException("非法参数:查询参数对象为null");
		}
		try {
			StringBuffer sbQueryString = new StringBuffer();			
			sbQueryString.append("select l from ChkRunLog as l where 1=1");
			if(qp.getOperDate() != null){
				sbQueryString.append(" and l.operDate=:operDate");
			}
			if(qp.getEtlProcID() != null){
				sbQueryString.append(" and l.etlProcID=:etlProcID");
			}
			if(qp.getPrepLevelID() != null){
				sbQueryString.append(" and l.prepLevelID=:prepLevelID");
			}
			if(qp.getRunStatus() != null){
				sbQueryString.append(" and l.runStatus=:runStatus");
			}
			return new CommQuery<ChkRunLog>().queryListPage(qp, 
					qp.appendOrders(sbQueryString, "l" ), getSession());
		} catch(RuntimeException re) {
			re.printStackTrace();
			return new  ListPage<ChkRunLog>();
		}
	}

	
}
